<template>
	<view>
		<u-sticky bgColor="#f7f7f7">
			<view class="mainpadding" style="position: relative; z-index: 2;padding-bottom: 0;">
				<view class="ffffff flexbetween ssbox">
					<view class="flexleft">
						<u-icon name="search" color="#999" size="20"></u-icon>
						<input type="text" placeholder="请输入搜索内容" class="hei_text main_size bold" v-model="keywords" confirm-type="search" @confirm="init">
					</view>
					<view class="rightss" @click="init">搜索</view>
				</view>
			</view>
		</u-sticky>
		<view class="mainpadding2">
			<view class="ffffff radius mainpadding2s margin_top flexbetween" v-for="item in list.data" :key="item.id" @click="tzspxq(item.id,item.goods_attr)">
				<image class="tupian" :src="item.image_text" mode=""></image>
				<view class="" style="width: 66%;">
					<view class="xiaohei ershil margin_top2 xiankuan1">{{item.title}}</view>
					<view class="flexleft margin_top2">
						<view class="fenbox margin_right1" v-show="Number(item.goodsprice.score_price)">积分抵扣￥{{item.goodsprice.score_price}}</view>
						<view class="huangbox margin_right1" v-show="Number(item.sdyh_price)">首单优惠￥{{item.sdyh_price}}</view>
						<view class="fenbox" v-show="Number(item.activity_price)">活动优惠￥{{item.activity_price}}</view>
					</view>
					<view class="flexleft margin_top2">
						<!-- <view class="xiaocheng fonweight strongtext margin_right4" v-if="item.goods_attr==1">￥{{(Number(item.goodsprice.price)-Number(item.goodsprice.score_price)-Number(item.sdyh_price)-Number(item.activity_price)).toFixed(2)}}</view> -->
						<!-- <view class="xiaocheng fonweight strongtext margin_right4" v-if="item.goods_attr==1">￥{{item.goodsprice.price}}</view> -->
						<view class="xiaohong sanshier bold" v-if="item.goods_attr==1"><text style="font-size: 16rpx;">￥</text>{{item.goodsprice.price}}</view>
						<view class="xiaohong sanshier bold" v-if="item.goods_attr==2">￥{{item.goodsprice.pt_price}}</view>
						<view class="xiaohong sanshier bold" v-if="item.goods_attr==3">￥{{item.goodsprice.ms_price}}</view>
						<!-- <view class="xiaohui smalltext zhonghuax">¥{{item.goodsprice.price}}</view> -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				keywords:""
			}
		},
		onLoad(options) {
			if(options.keywords){
				this.keywords = options.keywords
			}
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/goodscl/goodsList', 'GET', {
					page: page || 1,
					limit: _this.limit,
					keyword:this.keywords,
					goods_attr:1
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			tzspxq(id,attr) {
				uni.navigateTo({
					url: '/pages_lianmengsc/shangpxq?id='+id+"&attr="+attr
				})
			},
		}
	}
</script>

<style>
.tupian {
		width: 200rpx;
		height: 200rpx;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
	}
</style>
